<%@page import="com.alibaba.fastjson.JSONObject" %>
<%@page import="com.mrd.gtimp.business.repository.FundFlowDao" %>
<%@page import="com.mrd.util.SpringContextHolder" %>
<%@page import="java.text.SimpleDateFormat" %>
<%@ page pageEncoding="utf8" %>

<%
    response.setHeader("Content-Type", "application/javascript;charset=UTF-8");
    FundFlowDao dao = SpringContextHolder.getBean(FundFlowDao.class);//and b.confirm_time<to_date('201605','yyyymm')
    java.util.List<Object> 业务数据 = dao.findEntityBySql("select to_char(b.confirm_time, 'yyyy-mm-dd hh24:mi:ss'),b.business_id,  c.com_name cname,d.FAHUO_COMPANY_NAME,case when d.DECLARATION_TYPE='I' then '进' else '出' end, cc.com_name sname, d.DECLARATION_PORT,d.CONTAINER_NO,d.sno,1,df.free from t_biz_declaration d,(select * from T_BIZ_DECLARA_FREE where PAY_CONFIRM='1') df,  (t_biz_base_business b inner join t_sys_company c on b.CUSTOMER_COM_ID=c.com_id)  inner join t_sys_company cc on b.sup_id=cc.com_id  where df.DECLARATION_ID=d.id and d.id=b.id and b.confirm_time>=to_date('201603','yyyymm') and d.state not in ('DS00','DS03','DS030')", 0, 10, null);
    java.util.Map<Long, Object> mresult = new java.util.HashMap<Long, Object>();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    for (Object obj : 业务数据) {
        Object[] arrobj = (Object[]) obj;
        try {
            Long key = sdf.parse(arrobj[0].toString()).getTime() * 10;
            while (mresult.containsKey(key)) {
                key++;
            }
            mresult.put(key, arrobj);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    System.out.println(业务数据.size());
    System.out.println(mresult.keySet().size());


    java.util.List<Object> 充值数据 = dao.findEntityBySql("select to_char(f.REVIEW_DATE, 'yyyy-mm-dd hh24:mi:ss'), c.com_name, f.FUND_PAY_TYPE, f.amount from t_biz_fund_ajustment f inner join T_SYS_COMPANY c on f.com_id=c.com_id where f.state='SUCCESS' and f.review_date>=to_date('201603','yyyymm') ", 0, 10, null);
    java.util.Map<Long, Object> cresult = new java.util.HashMap<Long, Object>();
    for (Object obj : 充值数据) {
        Object[] arrobj = (Object[]) obj;
        try {
            Long key = sdf.parse(arrobj[0].toString()).getTime() * 10;
            while (cresult.containsKey(key)) {
                key++;
            }
            while (mresult.containsKey(key)) {
                System.out.println("unbelierble....");
                key++;
            }
            Object online = 0;
            Object offline = 0;
            if ("ONLINE".equals(arrobj[2].toString())) {
                online = arrobj[3];
            } else {
                offline = arrobj[3];
            }
            cresult.put(key, new Object[]{arrobj[0], arrobj[1], online, offline});
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    System.out.println(充值数据.size());
    System.out.println(cresult.keySet().size());
//out.write(JSONObject.toJSONString(mresult));
//out.flush();
%>
var 业务数据 = {
数据头:['业务提交时间','业务编号',
'实际委托人','收发货单位','业务类型（进/出）',
'业务供应商','申报口岸','集装箱号','报关单号',
'票数','报关费用'],
数据集:
<%=JSONObject.toJSONString(mresult) %>
};


var 充值数据 = {
数据头:['业务提交时间','实际委托人','线上充值','线下充值'],
数据集:
<%=JSONObject.toJSONString(cresult) %>
}
